package WaiBao;

import java.util.Arrays;

public class LiJingGe {
    public static void main(String[] args) {
        String[] name = {"张曼玉(班长)", "王知晓(副班长)", "小李(学习委员)", "李海海(团支书)", "王志阳", "王俊凯", "王源", "李浩东", "王培春", "王桂玲", "王多陪", "王绍培",
                "刘德华", "贾探春", "林黛玉", "王福文", "张娜", "王婷婷", "李杨凯", "李杨凯", "李存勖", "王多鱼", "李素", "周二磊", "王廷安", "毛泽勋", "刘保国", "杨荣耀",
                "杨幂", "李京格(学生)"};//考生本人:李京格(学生)
        int[] age = {21, 21, 20, 21, 19, 21, 21,21,20, 20, 18, 18, 21, 20, 21, 20, 18, 19, 18, 20, 19, 19, 20, 21, 20, 18, 20, 20, 21, 19};//考生年龄：19

        double[] jiefu1 = {65, 72, 82, 90, 75, 69, 78, 89, 80, 84, 91, 80, 85, 85, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 95, 77, 85, 95};
        double[] jiefu2 = {74, 85, 69, 76, 78, 75, 78, 69, 91, 70, 85, 75, 66, 95, 65, 75, 76, 90, 66, 98, 72, 71, 92, 86, 85, 88, 84, 64, 84, 96};
        double[] jiefu3 = {86, 76, 84, 85, 77, 66, 78, 69, 80, 80, 63, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 96};


        double boluo1;//代表每个学生的总分
        double boluo2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            boluo1 = jiefu1[i] + jiefu2[i] + jiefu3[i];
//            boluo2 = (boluo1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +boluo1);
//            System.out.println(name[i] + "的平均分为:" +boluo2);
//        }


        double titk1 = 0, titk2 = 0;
//        double[] cooc = new double[30];
//        for (int i = 0; i < 30; i++) {
//            titk1 =jiefu1[i] +jiefu2[i] + jiefu3[i];
//            titk2 = (titk1 * 1.0) / 3;
//            cooc[i] = titk2;
//        }
//
//        for (int i = 0; i < cooc.length - 1; i++) {
//            for (int j = 0; j <cooc.length - i - 1; j++) {
//                if (cooc[j] <cooc[j + 1]) {
//                    double tep = cooc[j];
//                    cooc[j] =cooc[j + 1];
//                    cooc[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(cooc[i]);
//        }


        double xigua1 = 0,  xigua2 = 0,  xigua3 = 0;//计算每门课的平均分
        double pingguo1 = 0,pingguo2 = 0, pingguo3 = 0;//计算每门课标准差
        double mihou1 = 0, mihou2 = 0, mihou3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <jiefu1.length; i++) {
            he += jiefu1[i];
        }
        xigua1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" +xigua1);
        double Sum = 0;
        for (int i = 0; i < jiefu2.length; i++) {
            Sum += jiefu2[i];
        }
        xigua2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + xigua2);
        double sum = 0;
        for (int i = 0; i < jiefu3.length; i++) {
            sum += jiefu3[i];
        }
        xigua3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + xigua3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < jiefu1.length; i++) {
            c1 += (jiefu1[i] - xigua1) * (jiefu1[i] - xigua1);
        }
        pingguo1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + pingguo1);
        for (int i = 0; i <jiefu2.length; i++) {
            c2 += (jiefu2[i] -xigua2) * (jiefu2[i] - xigua2);
        }
        pingguo2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + pingguo2);

        for (int i = 0; i < jiefu3.length; i++) {
            c3 += (jiefu3[i] - xigua3) * (jiefu3[i] -xigua3);
        }
        pingguo3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" +pingguo3);
////
//
//
        Arrays.sort(jiefu1);
        Arrays.sort(jiefu2);
        Arrays.sort(jiefu3);
        mihou1 = (jiefu1[14] + jiefu2[15]) * 1.0 / 2;
        mihou2 = (jiefu2[14] + jiefu2[15]) * 1.0 / 2;
        mihou3 = (jiefu3[14] + jiefu3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + mihou1);
        System.out.println("物理化学的中位数为:" + mihou2);
        System.out.println("电子与电工技术的中位数为:" + mihou3);





    }
}
